<template>
  <el-input
    v-bind="$attrs"
    @input="handleInput"
    placeholder="请输入公司编号"
    v-model.trim="companyCode"
    @blur="getCompany"
  ></el-input>
</template>

<script>
import carrier from "@/api/modules/carrier.js";
export default {
  name: "CarrierCompany",
  data() {
    return {
      companyCode: ""
    };
  },
  methods: {
    getCompany() {
      if (this.companyCode) {
        carrier.getCompany(this.companyCode).then((res) => {
          if (res.data) {
            console.log(res.data);
            // res.data.autoBalance = 1
            this.$emit("confirm", res.data.name);
          } else {
            this.companyCode = "";
          }
        });
      }
    },
    handleInput(value) {
      this.$emit("input", value);
    }
  }
};
</script>
